package cn.work.service;

import cn.work.bean.servicebean;
import cn.work.dao.serviceDao;

import javax.servlet.http.HttpServletResponse;
import java.sql.SQLException;
import java.util.List;

public class goodsService {
//    实例dao，调用dao方法
    private serviceDao gDao = new serviceDao();
//    新增数据
    public void insert(servicebean service){
        try {
            gDao.insert(service);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
//    获取数据
    public List<servicebean> getAllServices() throws SQLException {
        return gDao.getAllServices();
    }
//    查询
    public List<servicebean> searchServices( String query) throws SQLException {
        return gDao.search(query);
    }
//    批量删除
    public boolean deleteSelected(List<Integer> serviceIds, HttpServletResponse response) throws SQLException {
        return gDao.deleteSelected(serviceIds,response);
    }
 // 删除服务方法
    public boolean deleteService(int serviceId) {
        return gDao.deleteServiceById(serviceId);
    }
//    编辑修改
    public void update(servicebean service) {
        try {
            gDao.update(service);
        }catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

}
